﻿package com.winglish.as3.loader {
	import com.winglish.as3.loader.vo.LoaderClip;
	
	import flash.display.MovieClip;
	import flash.events.Event;
	import flash.display.LoaderInfo;

	public class LoaingBar extends LoaderClip {
		private var _mc:MovieClip = new MovieClip();
		
		public function LoaingBar(mc:MovieClip) {
			if (mc) {
				_mc = mc;
				super.loadingBarInit(_mc);
			}
		}
		
		public function progress( curByte:uint, totByte:uint, isScaleX:Boolean = true ): void {
			var loaded: uint = curByte;
			var total: uint = totByte;
			targetMc.mask = maskMc;
			if (isScaleX) maskMc.scaleX = (loaded / total);
			else maskMc.scaleY = (loaded / total);
			if (loaded / total == 1) {
				trace( "loaded complete" );
				dispatchEvent( new Event( "loadComplete", true ) );
			}
		}
	
	}
}